package com.cw.carwashproductcategory.service.impl;

import com.cw.carwashproductcategory.domain.ProductCategory;
import com.cw.carwashproductcategory.mapper.ProductCategoryMapper;
import com.cw.carwashproductcategory.service.ProductCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ProductCategoryServiceImpl implements ProductCategoryService {

    @Autowired
    private ProductCategoryMapper productCategoryMapper;

    @Override
    public List<ProductCategory> selectProductCategoryList(ProductCategory productCategory) {
        List<ProductCategory> categoryList = productCategoryMapper.selectProductCategoryList(productCategory);
        return categoryList;
    }

    @Override
    public int selectProductCategoryCount(ProductCategory productCategory) {
        int count = productCategoryMapper.selectProductCategoryCount(productCategory);
        return count;
    }

    @Override
    public ProductCategory selectProductCategoryById(Long id) {
        return productCategoryMapper.selectProductCategoryById(id);
    }

    @Override
    public int insertProductCategory(ProductCategory productCategory) {
        productCategory.setCreatedAt(new Date());
        return productCategoryMapper.insertProductCategory(productCategory);
    }

    @Override
    public int updateProductCategory(ProductCategory productCategory) {
        productCategory.setUpdatedAt(new Date());
        return productCategoryMapper.updateProductCategory(productCategory);
    }

    @Override
    public int deleteProductCategoryById(Long id) {
        return productCategoryMapper.deleteProductCategoryById(id);
    }

    @Override
    public int deleteProductCategoryByIds(Long[] ids) {
        return productCategoryMapper.deleteProductCategoryByIds(ids);
    }
}
